﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ChecklistMaintenance.aspx.cs" Inherits="PMP.Maintenance.ChecklistMaintenance" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
    <style type="text/css">
        .style1
        {
            width: 55%;
        }
        .style2
        {
            text-align: right;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    
        <table class="style1">
            <tr>
                <td class="style2">
                    Component:</td>
                <td>
                    <asp:DropDownList ID="ddlComponent" runat="server" AutoPostBack="True" 
                        DataSourceID="SqlDataSourceComponents" DataTextField="component" 
                        DataValueField="component" Height="25px" 
                        onselectedindexchanged="ddlComponent_SelectedIndexChanged" Width="200px">
                    </asp:DropDownList>
                    <asp:SqlDataSource ID="SqlDataSourceComponents" runat="server" 
                        ConnectionString="<%$ ConnectionStrings:LocalConnectionString %>" 
                        ProviderName="<%$ ConnectionStrings:LocalConnectionString.ProviderName %>" SelectCommand="select top 1 '' as [component] from [Checklist]
union
select top 1 '000-Create-New' as [component] from [Checklist]
union
SELECT [component] FROM [CheckList] ORDER BY [component]"></asp:SqlDataSource>
                    <asp:TextBox ID="txtComponent" runat="server" Height="25px" Visible="False" 
                        Width="200px"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td class="style2">
                    Checklist Item:</td>
                <td>
                    <asp:TextBox ID="txtChecklistItem" runat="server" Height="25px" Width="200px"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td class="style2">
                    Checklist Item Description:
                </td>
                <td>
                    <asp:TextBox ID="txtItemDesc" runat="server" Height="25px" Width="200px"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td class="style2">
                    <asp:Button ID="btnAdd" runat="server" onclick="btnAdd_Click" Text="Add" />
                    <asp:Button ID="btnClear" runat="server" onclick="btnClear_Click" 
                        Text="Clear" />
                </td>
                <td>
                    &nbsp;</td>
            </tr>
        </table>
    
    </div>
    <asp:GridView ID="grvCheckLists" runat="server" AutoGenerateColumns="False" 
        CellPadding="4" DataKeyNames="ID" DataSourceID="SqlDataSourceChecklists" 
        ForeColor="#333333" GridLines="Both">
        <RowStyle BackColor="#EFF3FB" />
        <Columns>
            <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
            <asp:BoundField DataField="component" HeaderText="component" 
                SortExpression="component" />
            <asp:BoundField DataField="item" HeaderText="item" SortExpression="item" />
            <asp:BoundField DataField="item_desc" HeaderText="item_desc" 
                SortExpression="item_desc" />
            <asp:BoundField DataField="exe_type" HeaderText="exe_type" 
                SortExpression="exe_type" />
            <asp:BoundField DataField="exe_id" HeaderText="exe_id" 
                SortExpression="exe_id" />
            <asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False" 
                ReadOnly="True" SortExpression="ID" />
        </Columns>
        <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
        <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
        <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
        <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
        <EditRowStyle BackColor="#2461BF" />
        <AlternatingRowStyle BackColor="White" />
    </asp:GridView>
    <asp:SqlDataSource ID="SqlDataSourceChecklists" runat="server" 
        ConnectionString="<%$ ConnectionStrings:LocalConnectionString %>" 
        DeleteCommand="DELETE FROM [CheckList] WHERE [ID] = ?" 
        InsertCommand="INSERT INTO [CheckList] ([component], [item], [item_desc], [exe_type], [exe_id], [ID]) VALUES (?, ?, ?, ?, ?, ?)" 
        ProviderName="<%$ ConnectionStrings:LocalConnectionString.ProviderName %>" 
        SelectCommand="SELECT [component], [item], [item_desc], [exe_type], [exe_id], [ID] FROM [CheckList] ORDER BY [component], [item]" 
        UpdateCommand="UPDATE [CheckList] SET [component] = ?, [item] = ?, [item_desc] = ?, [exe_type] = ?, [exe_id] = ? WHERE [ID] = ?">
        <DeleteParameters>
            <asp:Parameter Name="ID" Type="Int32" />
        </DeleteParameters>
        <UpdateParameters>
            <asp:Parameter Name="component" Type="String" />
            <asp:Parameter Name="item" Type="String" />
            <asp:Parameter Name="item_desc" Type="String" />
            <asp:Parameter Name="exe_type" Type="String" />
            <asp:Parameter Name="exe_id" Type="String" />
            <asp:Parameter Name="ID" Type="Int32" />
        </UpdateParameters>
        <InsertParameters>
            <asp:Parameter Name="component" Type="String" />
            <asp:Parameter Name="item" Type="String" />
            <asp:Parameter Name="item_desc" Type="String" />
            <asp:Parameter Name="exe_type" Type="String" />
            <asp:Parameter Name="exe_id" Type="String" />
            <asp:Parameter Name="ID" Type="Int32" />
        </InsertParameters>
    </asp:SqlDataSource>
    </form>
</body>
</html>
